/**
 *
 */
package org.insia.smartposse.manager.list;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.insia.smartposse.mapping.Categories;
import org.insia.smartposse.mapping.dao.CategoriesDAO;

/**
 * Class for create a Map of all Categorie in Database
 *
 * @author cmougel
 *
 */
public class CategorieMapManager extends HashMap {

	private final CategoriesDAO _dao = new CategoriesDAO();
	private HashMap<Integer, String> _categories = new HashMap<Integer, String>();

	public CategorieMapManager(){
		List<Categories> cs = _dao.findAll();
		for(Categories c : cs){
			_categories.put(c.getId(), c.getName());
		}
	}

	/**
	 * Return the map to use in select method
	 * @return
	 */
	public Map<Integer, String> getMap(){
		return _categories;
	}

	@Override
	public Object get(Object key) {
		return _categories.get(key);
	}

	@Override
	public int size() {
		return _categories.size();
	}
}
